package collections3;

/*
 * 学员类
 */

public class Students implements Comparable {
	private int id; // 学号
	private String name; // 姓名
	private String gender; // 性别
	private int age; // 年龄

	public Students() {

	}

	public Students(int id, String name, String gender, int age) {
		this.id = id;
		this.name = name;
		this.gender = gender;
		this.age = age;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	// 比较规则：根据student和this的年龄进行比较
	public int compareTo(Object o) {
		Students student = (Students) o;
		if (this.age == student.age) {
			return 0;
		}
		if (this.age > student.age) {
			return 1;
		} else {
			return -1;
		}
	}
}
